<?php
/*
Created by Chameleon Engineering, http://chameleonengineering.org
*/
?>
<div class="contenta">
<div class="box">
		<div class="box-heading"><?php echo $heading_title; ?></div>
	        <div id="shopbyprice" class="box-content">
	            <label for="amount"></label>
	            <span class="help-txt"><?php echo $text_min; ?> - <?php echo $text_max; ?>:</span>
	            <input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" readonly="" maxlength="20"/>
	            <div id="priceslider"></div>
	        </div>
	    </div>    
<?php
 GLOBAL $datalower;
 GLOBAL $datahigher;
 if (isset($this->session->data['lower'])&&isset($this->session->data['higher']))
 {
	$datalower=$this->session->data['lower'];
	$datahigher=$this->session->data['higher'];
}
else
{ 
$datalower=$this->config->get("min_shop_price");
$datahigher=$this->config->get("max_shop_price");
}
?>
<?php
if (!function_exists('curPageURL')) {
function curPageURL() {
$pageURL = 'http';
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
}
?>
<script>
  $(function() {
    var queryString = window.location.search;
    $( "#priceslider" ).slider({
      range: true,
      min:<?php echo $this->config->get("min_shop_price"); ?>,
      max: <?php echo $this->config->get("max_shop_price"); ?>,
      values: [ "<?php echo $datalower;?>","<?php echo $datahigher;?>"],
      slide: function( event, ui ) {$( "#amount" ).val(  + ui.values[ 0 ] + " - " + ui.values[ 1 ] );},
      change : function (event, ui) {
                                if  (queryString.indexOf("route") != -1)
                                {
			    $.ajax({
				url: 'index.php?route=product/category&path=' + '<?php echo $_GET['path']; ?>',
				dataType:'html',
				type: 'get',
				data:{ lower:ui.values[ 0 ], higher:ui.values[ 1 ]},
				success: function(html) {
				   location.reload();
				}
                                
			    }); 
                            }
                             else
                             {

                              $.ajax({
				url: '<?php echo curPageURL();?>',
				dataType:'html',
				type: 'get',
				data:{ lower:ui.values[ 0 ], higher:ui.values[ 1 ]},
				success: function(html) {
				   location.reload();
				}
                                
			    });  
                            }

}
    });
    $( "#amount" ).val(  + $( "#priceslider" ).slider( "values", 0 ) +
      " - " + $( "#priceslider" ).slider( "values", 1 ) );
  });
 </script>
</div>


